<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
  <div id="app" @click="aa" style="width: 100px;height: 100px;background-color: antiquewhite;">
  </div>
  <script>
    var vk = new Vue({
      el: app,
      data() {
        return {
          a: 1,
          b: "1",
          c: undefined,
          d: null,
          e: [1],
          f: {
            a: 1
          },
          $g: 12,
        }
      },

      created() {
        // this.$options表示vue实例的初始化选项，
        // 能够访问编写的任何vue方法，比如
        // this.$options.data(), this.$options.created();
        // 此选项常用来初始化数据（重置数据）
        this.$options.new_me = () => {
          Object.assign(this.$data, this.$options.data())
        }
      },
      methods: {
        aa() {
          console.log(this.a);
          this.a += 1;
          this.$options.data = function () {
            return {
              a: 21,
            }
          }
          if (this.a === 6)
            this.$options.new_me();
        }
      },
    })
  </script>
</body>

</html>